package com.tianji.learning.config;

import com.aliyun.green20220302.Client;
import com.aliyun.teaopenapi.models.Config;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class AliyunTextModerationPlusConfig {
    private final AliyunProperties aliyunProperties;

    @Bean
    public Client instance() throws Exception {
        Config config = new Config();
        //阿里云账号AccessKey
        config.setAccessKeyId(aliyunProperties.getAccessKeyId());
        config.setAccessKeySecret(aliyunProperties.getAccessKeySecret());
        //接入区域和地址
        config.setRegionId(aliyunProperties.getRegionId());
        config.setEndpoint(aliyunProperties.getEndpoint());
        //连接时超时时间，单位毫秒（ms）。
        config.setReadTimeout(6000);
        //读取时超时时间，单位毫秒（ms）。
        config.setConnectTimeout(3000);

        return new Client(config);
    }


}